package com.mew.mail.controller;

import com.mew.common.rest.mail.MailDetailInfoResponseMessage;
import com.mew.common.rest.mail.MailResponseMessage;
import com.mew.mail.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 邮件
 * @author dylin
 * @create 2021/4/2
 */
@Controller
@RequestMapping(value = "/mail")
public class MailController {
    @Autowired
    private MailService mailService;

    /**
     * 领取邮件
     * @param userId
     * @param mailId
     * @return
     */
    @PostMapping("/receive")
    @ResponseBody
    public int receiveAward(@RequestParam("userId")long userId,@RequestParam("mailId")int mailId){
        return mailService.receiveAward(userId,mailId);
    }
    /**
     * 查询邮件列表
     * @param userId
     * @return
     */
    @PostMapping("/query")
    @ResponseBody
    public MailResponseMessage getMailList(@RequestParam("userId") long userId){
        return mailService.getMailList(userId);
    }
    /**
     * 邮件相信信息
     * @return
     */
    @PostMapping("/detail_info")
    @ResponseBody
    public MailDetailInfoResponseMessage getDetailInfo(@RequestParam("mailId") int mailId){
        return mailService.getDetailInfo(mailId);
    }
}
